local json = require "cjson"
local jwt = require "resty.jwt"
-- 读取传过来的 PlateCode   用户名  用户Guid  时间 
local args =ngx.req.get_uri_args()
ngx.header.content_type="application/json;charset=utf8"
local rtn = {
    Data={},
    Error=nil,
    ErrorSrc="",
    ErrorCode="",
    IsPositive=true
}
-- ?PlateCode=Test&UserGuid=00000000-0000-0000-0000-000000000000&UserName=System
-- if(type(args.PlateCode) == "nil")
-- then
--     rtn.IsPositive= false;
--     rtn.Error = {};
--     rtn.Error.Msg = "请正确传入平台PlateCode";
--     ngx.say(json.encode(rtn));
--     return;
-- end

-- if(type(args.UserGuid) == "nil")
-- then
--     rtn.IsPositive= false;
--     rtn.Error = {};
--     rtn.Error.Msg = "请正确传入UserGuid";
--     ngx.say(json.encode(rtn));
--     return;
-- end

-- if(type(args.UserName) == "nil")
-- then
--     rtn.IsPositive= false;
--     rtn.Error = {};
--     rtn.Error.Msg = "请正确传入UserName";
--     ngx.say(json.encode(rtn));
--     return;
-- end

local jwt_token = jwt:sign(
    "5pil6aOO5YaN576O5Lmf5q+U5LiN5LiK5bCP6ZuF55qE56yR",
    {
        header={typ="JWT", alg="HS256"},
        payload={
            UserGuid="00000000-0000-0000-0000-000000000000",
            UserName="System",
            PlateCode="Test",
            LoginTime=ngx.localtime()
        }
    }
)
rtn.Data = jwt_token
ngx.say(json.encode(rtn));